package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.system.domain.TBaseStorageAreaLocation;
import com.ruoyi.system.domain.TMiStock;
import com.ruoyi.system.domain.UpdateStatusRequest;
import com.ruoyi.system.mapper.TBaseStorageAreaLocationMapper;
import com.ruoyi.system.mapper.TMiStockMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TOngoodsshelfMapper;
import com.ruoyi.system.domain.TOngoodsshelf;
import com.ruoyi.system.service.ITOngoodsshelfService;

/**
 * 【请填写功能名称】Service业务层处理
 *
 * @author ruoyi
 * @date 2024-09-07
 */
@Service
public class TOngoodsshelfServiceImpl implements ITOngoodsshelfService
{
    @Autowired
    private TOngoodsshelfMapper tOngoodsshelfMapper;
    @Autowired
    private TBaseStorageAreaLocationMapper tBaseStorageAreaLocationMapper;
    @Autowired
    private TMiStockMapper tMiStockMapper;


    /**
     * 查询【请填写功能名称】
     *
     * @param lotId 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public TOngoodsshelf selectTOngoodsshelfByLotId(String lotId)
    {
        return tOngoodsshelfMapper.selectTOngoodsshelfByLotId(lotId);
    }

    /**
     * 查询【请填写功能名称】列表
     *
     * @param tOngoodsshelf 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<TOngoodsshelf> selectTOngoodsshelfList(TOngoodsshelf tOngoodsshelf)
    {
        return tOngoodsshelfMapper.selectTOngoodsshelfList(tOngoodsshelf);
    }

    /**
     * 新增【请填写功能名称】
     *
     * @param tOngoodsshelf 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertTOngoodsshelf(TOngoodsshelf tOngoodsshelf)
    {
        return tOngoodsshelfMapper.insertTOngoodsshelf(tOngoodsshelf);
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param tOngoodsshelf 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateTOngoodsshelf(TOngoodsshelf tOngoodsshelf)
    {
        return tOngoodsshelfMapper.updateTOngoodsshelf(tOngoodsshelf);
    }

    /**
     * 批量删除【请填写功能名称】
     *
     * @param lotIds 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteTOngoodsshelfByLotIds(String[] lotIds)
    {
        return tOngoodsshelfMapper.deleteTOngoodsshelfByLotIds(lotIds);
    }

    /**
     * 删除【请填写功能名称】信息
     *
     * @param lotId 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteTOngoodsshelfByLotId(String lotId)
    {
        return tOngoodsshelfMapper.deleteTOngoodsshelfByLotId(lotId);
    }

    @Override
    public int updateStatus(List<TOngoodsshelf> request) {
        return tOngoodsshelfMapper.updateStatus(request);
    }

    @Override
    public TOngoodsshelf locl(String s) {
        return tOngoodsshelfMapper.locl(s);
    }

    @Override
    public int selectSts(String[] locationIds) {
        List<TMiStock> list = tMiStockMapper.selectSts(locationIds[0]);
        if(list.size()==0){
            return tBaseStorageAreaLocationMapper.updateLocationsStatus0(locationIds);
        }else if(list.get(0).getSTS().equals("0") || list.get(0).getSTS().equals("1")){
            return tBaseStorageAreaLocationMapper.updateLocationsStatus2(locationIds);
        }else {
            return tBaseStorageAreaLocationMapper.updateLocationsStatus1(locationIds);
        }

    }
}
